﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="detail.aspx.vb" Inherits="bookmeetprototype.detail" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <ul class="breadcrumb">
    <li><a id="A1" runat="server" href="~/Default.aspx">Home</a> <span class="divider">/</span></li>
    <li><a id="A2" runat="server" href="~/discover.aspx">Discover</a> <span class="divider">/</span></li>
     <li><a id="A3" runat="server" href="~/list.aspx">Book List</a> <span class="divider">/</span></li>
    <li class="active">Book Detail</li>
    <li style="float:right">
    <button runat="server" clientidmode="Static" id="add"  onserverclick="btnAddToLibrary" class="btn btn-small btn-primary" type="button">Add to Bookshelf</button>
    <button clientidmode="static" runat="server" id="success" class="btn btn-small btn-success" type="button">Added to Bookshelf</button></li>
    </ul>
    <!-- beginning of repeater to show book details -->
    <asp:Repeater ID="detailView" runat="server">
    <ItemTemplate>
    <div id="wrapper">
    <div id="first"><asp:Image ID="Image1" cssClass="floatimg" NullImageUrl="~/img/no_image.jpg" runat="server" Width="150px" ImageUrl='<%# Eval("imgurl")%>'/></div>
    <div id="second">
    <strong><%#Container.DataItem("Title")%></strong>&nbsp;<small>by&nbsp;</small><strong><%#Container.DataItem("Author")%></strong><h5>Date of Publication:</h5><small><%#DataBinder.Eval(Container.DataItem, "PublicationDate", "{0:D}")%></small>
    <h5>No. of Pages:</h5><small><%#Container.DataItem("Pages")%></small>
    <h5>Publisher:</h5><small><%#Container.DataItem("Publisher")%></small>
    <h5>Description:</h5>
    <small><%#Container.DataItem("Blurb")%></small>
    </div>
   </div>
    </ItemTemplate>
    </asp:Repeater>
    <!-- end of repeater -->
    
   

    <%-- Don't know if this is necessary? --%>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:BookMeetConnString %>" 
        ProviderName="<%$ ConnectionStrings:BookMeetConnString.ProviderName %>" 
        SelectCommand="SELECT [Title], [Author], [Description], [imgurl] FROM [booklist] WHERE ([ID] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter DefaultValue="1" Name="ID" QueryStringField="ID" 
                Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
   
    <%-- Comments Box --%>
     <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
        DataSourceID="CommentsDataSource" Height="167px" Width="641px" 
            GridLines="None" AllowPaging="True" 
        EmptyDataText="Sorry there are no comments for this book">
        <Columns>
          <asp:TemplateField HeaderText="Comments" ItemStyle-HorizontalAlign="Left">
            <ItemTemplate>

<div id="wrapper">
    <div id="first">
   <asp:Image ID="Image1" cssClass="img-polaroid" NullImageUrl="~/img/no_image.jpg" runat="server" Width="150px" ImageUrl='<%# Eval("AvatarURL","~/Account/{0}")%>'/>

    </div>
    <div id="second">
     <h4 class="tagline"><%# Eval("TagLine")%></h4>
            <h5 class="commentauthor"><%# Eval("BookCommenter")%></h5>
            <p><small><%# Eval("CommentBody")%></small></p>
        </div>
   </div>
            </ItemTemplate>
            <AlternatingItemTemplate>
          
      <div id="wrapper">
    <div id="first">
   <asp:Image ID="Image1" cssClass="img-polaroid" NullImageUrl="~/img/no_image.jpg" runat="server" Width="150px" ImageUrl='<%# Eval("AvatarURL","~/Account/{0}")%>'/>

    </div>
    <div id="second">
     <h4 class="tagline"><%# Eval("TagLine")%></h4>
            <h5 class="commentauthor"><%# Eval("BookCommenter")%></h5>
            <p><small><%# Eval("CommentBody")%></small></p>
        </div>
   </div>
                      
            </AlternatingItemTemplate>

<ItemStyle HorizontalAlign="Left"></ItemStyle>
            </asp:TemplateField>
        </Columns>

         <HeaderStyle Font-Bold="True" Font-Italic="False" Font-Size="X-Large" 
             Height="50px" HorizontalAlign="Left" />

    </asp:GridView>

<asp:SqlDataSource ID="commentsDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:BookMeetConnString %>" 
        ProviderName="<%$ ConnectionStrings:BookMeetConnString.ProviderName %>" 
        SelectCommand="SELECT comments.BookCommenter, userprofiles.AvatarURL, comments.TagLine, comments.CommentBody FROM comments INNER JOIN userprofiles ON comments.BookCommenter = userprofiles.TravellerName WHERE ([BookID] = ?)">
        <SelectParameters>
            <asp:QueryStringParameter Name="BookID" QueryStringField="ID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
   

    
    <asp:Label ID="mustberegisteredtoleaveacomment" runat="server" 
        Font-Italic="True" Font-Size="Small" ForeColor="Red" 
        Text="(You must be registered to leave a comment)"></asp:Label>
    <br />
    &nbsp;<br />
    Title
    <br />
    <asp:TextBox ID="tb_Subject" runat="server" Width="319px"></asp:TextBox>
    <br />
    Your Comment
    <br />
    <asp:TextBox ID="tb_Message" runat="server" Height="146px" Width="337px" 
        TextMode="MultiLine"></asp:TextBox>
    <br />
    <br />
    <asp:Button ID="Button1" runat="server" Text="Submit" Width="148px" />
    </strong>
    <%# Eval("CommentBody")%>
<br />
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="SidebarContent" runat="server">
    <h4>Add a tag for this book!</h4> (separate multiple tags with a comma)<br />
    <asp:TextBox ID="tb_NewTags" runat="server" Width="201px" Height="26px"></asp:TextBox>
    <strong>All Tags:</strong>
    <asp:CheckBoxList ID="CheckBoxList1" runat="server" 
        DataSourceID="SqlDataSource2" DataTextField="Tag" DataValueField="ID" 
        RepeatDirection="Vertical">
    </asp:CheckBoxList>

    <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
        ConnectionString="<%$ ConnectionStrings:BookMeetConnString %>" 
        ProviderName="<%$ ConnectionStrings:BookMeetConnString.ProviderName %>" 
        SelectCommand="SELECT [ID], [Tag] FROM [tag]"></asp:SqlDataSource>

    <br />
    <asp:Button ID="Button2" runat="server" Text="Add Your Tag!" Width="119px" />

<br />
    <br /><table style="background-color:#FFFFFF" width="200" cellpadding="1" cellspacing="1">
	<tr>
		<td><asp:HyperLink   
            ID="returntolistdetail"   
            runat="server"  
            Text="Return to the list"  
            NavigateUrl="~/list.aspx"  
            > </asp:HyperLink></td>
		<td><asp:HyperLink   
            ID="addabook"   
            runat="server"  
            Text="Add A Book!"  
            NavigateUrl="~/addbook.aspx"  
            > </asp:HyperLink></td>
	</tr>
</table></asp:Content>